package book;

/**
 * Created with IntelliJ IDEA.
 * User:xieChao
 * Date:2022/9/25 10:53
 */
public class BookList {
    private Book[] books = new Book[10];
    private int usedSize;
    public BookList(){
        books[0] = new Book("西游记","吴承恩",23,"小说");
        books[1] = new Book("红楼梦","曹雪芹",129,"文学");
        books[2] = new Book("文化苦旅","余秋雨",27,"文学");
        books[3] = new Book("晚熟的人","莫言",18,"文学");
        this.usedSize = 4;
    }

    public int getUsedSize() {
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }

    /**
     * 获取pos位置的一本书
     * @param pos
     * @return
     */

    public Book getPos(int pos){
        return this.books[pos];
    }

    /**
     * 设置pos下标为一本书,添加一本书
     * @param pos
     * @param book
     */
    public void setBook(int pos,Book book){
        this.books[pos] = book;
    }
}
